package org.example.new_hbps_backend_reconstruction.config;



import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.SecurityFilterChain;
/**
 * @author 丁利军
 * @date 2025年10月10日 21:53
 * @description spring security 配置
 */
@Configuration
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        // 1. 关闭默认的登录页 & Basic Auth 弹窗
        http.httpBasic(httpBasic -> httpBasic.disable())
                .formLogin(form -> form.disable());

        // 2. 关闭 CSRF（否则 POST 请求会被拦）
        http.csrf(csrf -> csrf.disable());

        // 3. 放行所有请求（你自己用拦截器控制）
        http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll());

        return http.build();
    }
}

